<?php
namespace App\Repository\Db;

use App\Repository\Contracts\FaqInterface;
use Illuminate\Support\Facades\DB;

/**
 * @Author:: HuangYin
 * @DateTime: 2017-01-16 11:56
 *
 * @Description:
 */
class FaqRepository extends Repository implements FaqInterface
{
    protected function modelName()
    {
        return 'App\Model\Faq';
    }

    public function detail($id)
    {
        return $this->find($id);
    }

    public function lists($limit, $page)
    {
        $query = $this->model;
        $total = $query->count();
        $list = $query->orderBy('id', 'desc')->simplePaginate($limit, ['*'], 'page', $page);

        return $this->simplePaginate('list', $list->items(), $total, ceil($total/$limit), $page);
    }

    public function findIdForFirst()
    {
        return $this->model->first(['faq_id']);
    }
}